<?php

namespace App\Admin\Forms\Project\Steps;

use App\Models\AdminUser;
use Encore\Admin\Widgets\Box;
use Encore\Admin\Widgets\Form;
use Encore\Admin\Widgets\StepForm;
use Illuminate\Http\Request;

class Info extends StepForm
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = 'Basic info';

    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request)
    {
        $this->clear();

        return $this->next($request->all());
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $box = new Box('','content');
        $this->html($box->solid()->view('tt'))->style('background','red')->setWidth(12,0);
        $this->display('code',__('project.code'))->default(111);
        $this->text('name',__('project.name'))->required();
        $this->select('fzr',__('project.fzr'))->options(AdminUser::userOptions())->required();
        $this->select('department_id',__('Department'))->options(department_options())->required();
        $this->radio('state',__('project.state'))
            ->options(project_status_options())->required();
        $this->text('subject',__('project.subject'))->required();
        $this->select('project_category_id',__('project.category'))
            ->options(project_category_options())->required();
        $this->radio('subject_type_id',__('project.subject_type'))
            ->options(project_subject_type_options())->required();
        $this->select('project_level_id',__('project.level'))
            ->options(project_level_options())->required();
        $this->text('project_source',__('project.source'))->required();
        $this->date('authorize_date',__('project.authorize_date'))->required()->format("YYYY-MM");
        $this->date('start_date',__('project.start_date'))->required()->format("YYYY-MM");
        $this->date('plan_end_date',__('project.plan_end_date'))->required()->format("YYYY-MM");
        $this->decimal('fee_authorize', __('project.fee_authorize'))->required()->default(0);
        $this->decimal('attach_fee', __('project.attach_fee'))->default(0);
        $this->decimal('out_fee', __('project.out_fee'))->default(0);

        $this->table('department', 'Table', function ($form) {
//            $form->text('name');
//            $form->email('email');
//            $form->ip('ip');
        });
    }

    public function render()
    {
        return 33;
        return parent::render(); // TODO: Change the autogenerated stub
    }
}
